<div class="row m-n">
    <div class="crumbs-bar">
        <div yb-crumbs></div>
    </div>
    <div tabset type="tab">
        <div tab heading="劳务费用结算" active="activeFlag[0]" ng-click="changeTab(0)">
            <div class="row wrapper-y-sm">
                <div class="operate-bar col-xs-4 font-0">
                    <button class="btn btn-operate m-r-sm" ng-click="addCheck()" ng-disabled="!btnPermission.settlementOfServiceExpensesAdd"
                        translate translate-attr-title="{{!btnPermission.settlementOfServiceExpensesAdd?'无权限执行此操作':''}}">新增</button>
                </div>
                <div class="search-bar wrapper-none col-xs-8">
                    <div class="btn-group m-l-xs pull-right">
                        <button type="button" class="btn btn-default base-color" ng-click="search()" translate translate-attr-title="刷新">
                            <i class="yb-icon ico-refresh"></i>
                        </button>
                        <button type="button" class="btn btn-default base-color" translate translate-attr-title="配置表格列"
                            ng-click="switchToolbar('ColConfig');">
                            <i class="yb-icon ico-set"></i>
                        </button>
                        <div class="btn btn-default base-color" ng-if="!!btnPermission.settlementOfServiceExpensesExport">
                            <div translate-attr-title="导出">
                                <i class="yb-icon ico-export-o"></i>
                            </div>
                            <ul class="more-tool">
                                <li yb-download download-url="exportParam.sectionUrl"
                                    download-param="exportParam.sectionParam" download-key="ids">
                                    <i class="yb-icon ico-export-o"></i><span translate>导出</span> 
                                </li>
                                <li yb-download download-url="exportParam.allUrl" download-param="condition" download-duration="3">
                                    <i class="yb-icon ico-export-o"></i><span translate>导出全部</span>
                                </li>
                            </ul>
                        </div>
                    </div>
                    <button class="btn-advance pull-right m-l-xs" ng-click="switchToolbar('AdvanceSearch')" translate-attr-title="高级搜索" translate="高级搜索more">
                    </button>
                    <div class="input-group pull-right clearfix">
                        <input type="text" class="form-control txt-search" translate translate-attr-placeholder="劳务费用结算单"
                            ng-model="condition.billNo">
                        <span class="input-group-addon cursor-pointer" ng-click="search(1)" translate>搜索</span>
                    </div>
                </div>
            </div>
            <div yb-advance-search show-toolbar="toolbarConfig.showAdvanceSearch" search-data="search(1)"
                reset-data="reset()">
                <div class="advance-search m-t-sm">
                    <div class="form-group clearfix">
                        <label class="control-label"><span translate> 劳务费用结算单</span>：</label>
                        <input type="text" ng-model="condition.billNo" class="form-control">
                    </div>
                    <div class="form-group clearfix">
                        <label class="control-label"><span translate>客户名称</span>：</label>
                        <input type="text" ng-model="condition.saleNo" class="form-control">
                    </div>
                    <div class="form-group clearfix">
                        <label class="control-label"><span translate>创建人</span>：</label>
                        <input type="text" ng-model="condition.createName" class="form-control">
                    </div>

                    <div class="form-group clearfix m-b-none">
                        <label class="control-label"><span translate>创建时间</span>：</label>
                        <input type="text" class="form-control date-picker" ng-model="condition.createDateStart"
                            datepicker-popup="{{'yyyy-MM-dd'}}" ng-click="showCreateDateStart = !showCreateDateStart"
                            ng-change="checkDate(condition, 'createDateStart', 'createDateEnd')"
                            is-open="showCreateDateStart" close-text="关闭" modal-size="small" readonly>
                    </div>
                    <div class="form-group clearfix m-b-none">
                        <label class="control-label"></label>
                        <label class="control-label wave-line">~</label>
                    </div>
                    <div class="form-group clearfix">
                        <label class="control-label"></label>
                        <input type="text" class="form-control date-picker" ng-model="condition.createDateEnd"
                            datepicker-popup="{{'yyyy-MM-dd'}}" ng-click="showCreateDateEnd = !showCreateDateEnd"
                            ng-change="checkDate(condition, 'createDateStart', 'createDateEnd')"
                            is-open="showCreateDateEnd" close-text="关闭" modal-size="small" readonly>
                    </div>

                    <div class="form-group clearfix">
                        <label class="control-label"><span translate>审核状态</span>：</label>
                        <select ng-model="condition.status" class="form-control"
                            ng-options="item.id as item.name for item in auditStatusList">
                            <option value="" translate>请选择</option>
                        </select>
                    </div>
                </div>
            </div>
            <div yb-col-config show-toolbar="toolbarConfig.showColConfig" ng-model="tableConfig" col-fixed="true"
                has-check-col="true" set-tb-style="setFixedWidth()"></div>
            <div class="main-area">
                <div yb-table-fixed class="table-fixed-wrap fix-left" ele-count="4" scroll-area="right">
                    <div class="th-fixed">
                        <table class="table-fixed border-none" width="{{tableConfig.fixedWidth}}">
                            <thead>
                                <tr>
                                    <th width="40" class="text-center th-check border-l-none">
                                        <div yb-check-box yb-checked="markInfo.allChecked" yb-click="selectAll()"></div>
                                    </th>
                                    <th ng-repeat="itemCol in tableConfig.tableCol track by $index"
                                        ng-show="!!itemCol.isShow && !!itemCol.isFixed"  width="{{itemCol.width}}">
                                        <div yb-thead-operate ng-model="itemCol" target-width="tableConfig.fixedWidth"
                                            fixed-width="tbStyle.billFixedWidth"></div>
                                    </th>
                                </tr>
                            </thead>
                        </table>
                    </div>
                    <div class="th-scroll-x" ng-style="tbStyle.billFixedWidth">
                        <table class="table-fixed border-none" width="{{tableConfig.scrollWidth}}">
                            <thead>
                                <tr>
                                    <th ng-repeat="itemCol in tableConfig.tableCol track by $index"
                                        ng-show="(!!itemCol.isShow && !itemCol.isFixed)"  width="{{itemCol.width}}">
                                        <div yb-thead-operate ng-model="itemCol" target-width="tableConfig.scrollWidth">
                                        </div>
                                    </th>
                                </tr>
                            </thead>
                        </table>
                    </div>
                    <div class="td-scroll-y" ng-show="dataList.length > 0">
                        <table class="table-fixed border-none" width="{{tableConfig.fixedWidth}}">
                            <tbody>
                                <tr ng-repeat="item in dataList track by $index"
                                    ng-class="{'row-selected': $index === markInfo.cueRow}"
                                    ng-click="selectRow($index)">
                                    <td width="40" class="text-center border-l-none">
                                        <div yb-check-box yb-checked="item.isChecked"
                                            yb-click="selectSingle(item, dataList, 'Bill')"></div>
                                    </td>
                                    <td class="spill-dots" ng-repeat="itemCol in tableConfig.tableCol track by $index"
                                        width="{{itemCol.width}}" ng-show="!!itemCol.isShow && !!itemCol.isFixed"
                                        title="{{item[itemCol.dataField]}}">
                                        <div>
                                            <button type="button" class="btn btn-operate m-r-xs"
                                                ng-click="editCheck(item)"
                                                ng-disabled="item.status!=0 || !btnPermission.settlementOfServiceExpensesEdit"
                                                translate translate-attr-title="{{!btnPermission.settlementOfServiceExpensesEdit?'无权限执行此操作':''}}">编辑
                                            </button>
                                            <button type="button" class="btn btn-operate m-r-xs"
                                                ng-disabled="item.status!=0&&btnPermission.settlementOfServiceExpensesAudit"
                                                ng-click="go2checkData(item)"
                                                    translate translate-attr-title="{{!btnPermission.settlementOfServiceExpensesAudit?'无权限执行此操作':''}}">审核</button>
                                            <button type="button" class="btn btn-operate m-r-xs"
                                                    ng-disabled="item.status!=0&&btnPermission.settlementOfServiceExpensesRemove"
                                                    ng-click="delData(item)"
                                                    translate translate-attr-title="{{!btnPermission.settlementOfServiceExpensesRemove?'无权限执行此操作':''}}">删除</button>
                                            <button type="button" class="btn btn-operate m-r-xs"
                                                ng-click="printBill(item)" translate>打印</button>

                                        </div>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="td-scroll" ng-show="dataList.length > 0" ng-style="tbStyle.billFixedWidth">
                        <table class="table-fixed border-none" width="{{tableConfig.scrollWidth}}">
                            <tbody>
                                <tr ng-repeat="item in dataList track by $index"
                                    ng-class="{'row-selected': $index === markInfo.cueRow}"
                                    ng-click="selectRow($index)">
                                    <td class="spill-dots" ng-repeat="itemCol in tableConfig.tableCol track by $index"
                                        width="{{itemCol.width}}" title="{{item[itemCol.dataField]}}"
                                        ng-show="(!!itemCol.isShow && !itemCol.isFixed)||(!!itemCol.isSap&&!isZHJCH)">
                                        <div ng-switch="itemCol.type">
                                            <div ng-switch-when="click">
                                                <a class="btn-operate m-r-xs"
                                                    ng-class="{'danger-color': !!item.isReverse}"
                                                    ng-click="tdClick(item, itemCol.clickFn)">
                                                    {{item[itemCol.dataField]}}
                                                </a>
                                            </div>
                                            <div ng-switch-default class="spill-dots">
                                                <span ng-class="{'danger-color': !!item.isReverse}">{{item[itemCol.dataField]}}</span>
                                            </div>
                                        </div>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="no-data w-full text-center p-t" ng-show="dataList.length === 0" translate>暂时没有数据</div>
                </div>
            </div>
            <div class="bottom-area page-bar wrapper-y-sm clearfix">
                <div yb-check-box class="m-t-xs m-r-sm" yb-checked="markInfo.allChecked" yb-check-name="全选"
                    yb-click="selectAll()"></div>
                <div yb-page-info ng-model="pageInfo" yb-refresh="search()"></div>
            </div>
        </div>
        <!-- 新增、编辑 -->
        <div tab heading="{{tabFlag.name}}" active="activeFlag[1]" ng-if="activeFlag[1] ">
            <div class="pos-a-full shuttle-box left" style="right: 65%;top: 35px;">
                <div class="box-head clearfix">
                    <span class="font-14" translate>
                        差价核算信息
                    </span>
                </div>
                <div class="pos-a-full box-body has-head has-foot border-t">
                    <form name="checkForm" class="main-wrap form-horizontal form-up-tb p-t clearfix" novalidate>
                        <div class="form-group col-xs-12">
                            <label class="col-xs-3 control-label"><i>*</i><span translate>客户名称</span>：</label>
                            <div class="col-xs-8 wrapper-none">
                                <input type="text" name="dealerName" class="form-control light-bg"
                                    ng-model="orderObj.dealerName" ng-click="selectDealer()"
                                    required yb-focus readonly required yb-focus readonly
                                    ng-disabled="orderObj.id"
                                    translate translate-attr-placeholder="请选择">

                                <div class="msg-block"
                                    ng-show="checkForm.purchaseOrgName.$dirty || (checkForm.purchaseOrgName.$invalid && submitted)">
                                    <div class="error-msg"
                                        ng-if="checkForm.purchaseOrgName.$error.required && !checkForm.purchaseOrgName.focused">
                                        <div class="msg-triangle"></div>
                                        <span translate>必填项，请填写</span>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="form-group col-xs-12">
                            <label class="col-xs-3 control-label"><span translate>客户编码</span>：</label>
                            <div class="col-xs-8 wrapper-none">
                                <input type="text" name="dealerCode" disabled class="form-control"
                                    ng-model="orderObj.dealerCode" maxlength="200">
                            </div>
                        </div>

                        <div class="form-group col-xs-12">
                            <label class="col-xs-3 control-label"><i>*</i><span translate>实际收款金额</span>：</label>
                            <div class="col-xs-8 wrapper-none">
                                <input type="text" name="allTotalRealPrice" class="form-control" ng-model="orderObj.allTotalRealPrice"
                                    yb-number-input negative="true"
                                    ng-disabled="true" yb-focus
                                    translate translate-attr-placeholder="请选择经销商差价核算单" max="9999999999.999"
                                    disable-decimal="false" decimal-places="2">

                                <div class="msg-block" ng-show="checkForm.allTotalRealPrice.$dirty || submitted">
                                    <div class="error-msg"
                                        ng-if="(!orderObj.allTotalRealPrice) && !checkForm.allTotalRealPrice.focused">
                                        <div class="msg-triangle"></div>
                                        <span translate>实际收款金额不能为空</span>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="form-group col-xs-12">
                            <label class="col-xs-3 control-label"><span translate>应收金额</span>：</label>
                            <div class="col-xs-8 wrapper-none">
                                <input type="text" name="allTotalAdjust" class="form-control" ng-model="orderObj.allTotalAdjust"
                                       yb-number-input negative="true"
                                        yb-focus  ng-disabled="true"
                                       translate translate-attr-placeholder="请选择经销商差价核算单" max="9999999999.999"
                                       disable-decimal="false" decimal-places="2">
                            </div>
                        </div>

                        <div class="form-group col-xs-12">
                            <label class="col-xs-3 control-label"><i>*</i><span translate>差价</span>：</label>
                            <div class="col-xs-8 wrapper-none">
                                <input type="text" name="allTotalMargin" class="form-control" ng-model="orderObj.allTotalMargin"
                                       yb-number-input negative="true"
                                        yb-focus  ng-disabled="true"
                                       translate translate-attr-placeholder="请选择经销商差价核算单" max="9999999999.999"
                                       disable-decimal="false" decimal-places="2">

                                <div class="msg-block" ng-show="checkForm.allTotalMargin.$dirty || submitted">
                                    <div class="error-msg"
                                         ng-if="(!orderObj.allTotalMargin) && !checkForm.allTotalMargin.focused">
                                        <div class="msg-triangle"></div>
                                        <span translate>差价不能为空</span>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="form-group col-xs-12" >
                            <label class="col-xs-3 control-label"><span translate>经办人</span>：</label>
                            <div class="col-xs-8 wrapper-none">
                                <input type="text" name="agent"  class="form-control"
                                       ng-model="orderObj.agent" maxlength="200">
                            </div>
                        </div>
                        <div class="form-group col-xs-12">
                            <label class="col-xs-3 control-label"><span translate>备注</span>：</label>
                            <div class="col-xs-8 wrapper-none">
                                <textarea type="text" name="remark" class="form-control full" ng-model="orderObj.remark"
                                    maxlength="200"></textarea>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="bottom-area btn-bar text-center border-t clearfix">
                    <button type="button" class="btn btn-primary m-r-sm" ng-click="saveData(checkForm.$valid)" translate>保存</button>
                    <button type="button" class="btn btn-default" ng-click="changeTab(0)" translate>取消</button>
                </div>
            </div>
            <div class="pos-a-full shuttle-box right" style="left: 35%;top: 35px;bottom: 10px">
                <div class="box-head clearfix">
                    <span class="font-14 pull-left" translate>经销商差价核算单</span>
                    <input type="text" class="form-control saleNo-input pull-right" translate translate-attr-placeholder="经销商差价核算单号"
                         ng-model="condition2.distributionNo">
                    <button class="saleNo-button pull-right btn btn-default" ng-click="searchSaleNo()" translate>搜索</button>
                </div>
                <div class="pos-a-full box-body has-head border-t ">
                    <div yb-table-fixed class="table-fixed-wrap " style="top: 15px;left: 0 ">
                        <div class="th-scroll-x ">
                            <table class="table-fixed border-none " width="{{addTableInfo.tableConfig.scrollWidth}} ">
                                <thead>
                                    <tr>
                                        <th width="40" class="text-center th-check border-l-none ">
                                            <div yb-check-box yb-checked="addTableInfo.markInfo.allChecked"
                                                yb-click="addTableInfo.selectAll() ">
                                            </div>
                                        </th>
                                        <th ng-repeat="itemCol in addTableInfo.tableConfig.tableCol track by $index "
                                            width="{{itemCol.width}} "
                                            ng-show="!!itemCol.isShow">
                                            <div yb-thead-operate ng-model="itemCol "
                                                target-width="addTableInfo.tableConfig.scrollWidth "></div>
                                        </th>
                                    </tr>
                                </thead>
                            </table>
                        </div>
                        <div class="td-scroll" ng-show="addTableInfo.dataList.length> 0">
                            <table class="table-fixed border-none" width="{{addTableInfo.tableConfig.scrollWidth}}">
                                <tbody>
                                    <tr ng-repeat="item in addTableInfo.dataList track by $index"
                                        ng-class="{'row-selected': $index === addTableInfo.markInfo.curRow}"
                                        ng-click="addTableInfo.selectRow($index)">
                                        <td width="40" class="text-center border-l-none">
                                            <div yb-check-box yb-checked="item.isChecked"
                                                yb-click="addTableInfo.selectSingle(item)"></div>
                                        </td>
                                        <td class="spill-dots"
                                            ng-repeat="itemCol in addTableInfo.tableConfig.tableCol track by $index"
                                            width="{{itemCol.width}}"
                                            ng-show="!!itemCol.isShow"
                                            title="{{item[itemCol.dataField]}}"
                                            ng-style="{'overflow':item.chpErrMsg?'unset':'hidden'}">
                                            <div ng-switch="itemCol.type">
                                                <div ng-switch-when="click">
                                                    <a class="btn-operate m-r-xs"
                                                        ng-click="addTableInfo.tdClick(item, itemCol.clickFn)">
                                                        {{item[itemCol.dataField]}}
                                                    </a>
                                                </div>
                                                <div ng-switch-default>
                                                    <span
                                                        ng-if="!item.isChecked || !itemCol.needInput">{{item[itemCol.dataField]}}</span>
                                                    <div class="td-edit pos-r"
                                                        ng-if="item.isChecked && itemCol.needInput">
                                                        <input type="text" class="form-control"
                                                            ng-model="item[itemCol.dataField]" yb-number-input
                                                            negative="true" max="99999999.99" disable-decimal="false"
                                                            decimal-places="2" ng-class="{'error': item.chpErr }" >
                                                    </div>
                                                </div>
                                            </div>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                        <div class="no-data w-full text-center p-t" ng-show="addTableInfo.dataList.length === 0" translate >
                            暂时没有数据
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!-- 审核、详情 -->
        <div tab heading="{{tabFlagName}}" active="activeFlag[3]" ng-if="activeFlag[3] ">
            <div class="pos-a-full shuttle-box left" style="right: 65%;top: 35px;">
                <div class="box-head clearfix">
                    <span class="font-14" translate>
                        差价核算信息
                    </span>
                </div>
                <div class="pos-a-full box-body has-head has-foot border-t">
                    <form name="checkForm" class="main-wrap form-horizontal form-up-tb p-t clearfix" novalidate>
                        <div class="form-group col-xs-12">
                            <label class="col-xs-4 control-label"><span translate>客户名称</span>：</label>
                            <label class="col-xs-8 control-label p-l-n text-left spill-dots">
                                {{detailObj.dealerName || "-"}}
                            </label>
                        </div>
                        <div class="form-group col-xs-12">
                            <label class="col-xs-4 control-label"><span translate>客户编号</span>：</label>
                            <label class="col-xs-8 control-label p-l-n text-left spill-dots">
                                {{detailObj.dealerCode || "-"}}
                            </label>
                        </div>
                        <div class="form-group col-xs-12">
                            <label class="col-xs-4 control-label"><span translate>实际收款金额</span>：</label>
                            <label class="col-xs-8 control-label p-l-n text-left spill-dots">
                                {{(detailObj.allTotalRealPrice ) || "-"}}
                            </label>
                        </div>
                        <div class="form-group col-xs-12">
                            <label class="col-xs-4 control-label"> <span translate>应收金额</span>：</label>
                            <label class="col-xs-8 control-label p-l-n text-left spill-dots">
                                {{(detailObj.allTotalAdjust) || "-"}}
                            </label>
                        </div>
                        <div class="form-group col-xs-12" >
                            <label class="col-xs-4 control-label"> <span translate>差价</span>：</label>
                            <label class="col-xs-8 control-label p-l-n text-left spill-dots">
                                {{detailObj.allTotalMargin|| "-"}}
                            </label>
                        </div>
                        <div class="form-group col-xs-12">
                            <label class="col-xs-4 control-label"><span translate>经办人</span>：</label>
                            <label class="col-xs-8 control-label p-l-n text-left spill-dots">
                                {{detailObj.agent || "-"}}
                            </label>
                        </div>
                        <div class="form-group col-xs-12">
                            <label class="col-xs-4 control-label"><span translate>备注</span>：</label>
                            <label class="col-xs-8 control-label p-l-n text-left spill-dots">
                                {{detailObj.remark || "-"}}
                            </label>
                        </div>
                        <div class="form-group col-xs-12" ng-if="isCheckFlag" style="left: 10%; width: 280px;">
                            <textarea yb-word-count max-size="500" name="auditMessage" class="form-control full"
                                      ng-model="orderObj.auditMessage" ng-class="{'error': !orderObj.auditMessage && submitted}"
                                      translate translate-attr-placeholder="审核意见"></textarea>
                        </div>
                    </form>
                </div>
                <div class="bottom-area btn-bar text-center border-t clearfix" ng-if="isCheckFlag">
                    <button type="button" class="btn btn-primary m-r-sm"
                        ng-click="checkData(detailObj.id,1)" translate>通过</button>
                    <button type="button" class="btn btn-primary m-r-sm"
                            ng-click="checkData(detailObj.id,2)" translate>拒绝</button>
                    <button type="button" class="btn btn-default" ng-click="changeTab(0)" translate>取消</button>
                </div>
            </div>
            <div class="pos-a-full shuttle-box right" style="left: 35%;top: 35px;bottom: 10px">
                <div class="box-head clearfix">
                    <span class="font-14" translate>
                        销售订单
                    </span>
                </div>
                <div class="pos-a-full box-body has-head border-t">
                    <div yb-table-fixed class="table-fixed-wrap" style="top: 15px;left: 0">
                        <div class="th-scroll-x">
                            <table class="table-fixed border-none" width="{{detailTableInfo.tableConfig.scrollWidth}}">
                                <thead>
                                    <tr>
                                        <th ng-repeat="itemCol in detailTableInfo.tableConfig.tableCol track by $index"
                                            width="{{itemCol.width}}"
                                            ng-show="!!itemCol.isShow">
                                            <div yb-thead-operate ng-model="itemCol"
                                                target-width="detailTableInfo.tableConfig.scrollWidth"></div>
                                        </th>
                                    </tr>
                                </thead>
                            </table>
                        </div>
                        <div class="td-scroll" ng-show="detailTableInfo.dataList.length > 0">
                            <table class="table-fixed border-none" width="{{detailTableInfo.tableConfig.scrollWidth}}">
                                <tbody>
                                    <tr ng-repeat="item in detailTableInfo.dataList track by $index"
                                        ng-class="{'row-selected': $index === detailTableInfo.markInfo.curRow}"
                                        ng-click="detailTableInfo.selectRow($index)">
                                        <td class="spill-dots"
                                            ng-repeat="itemCol in detailTableInfo.tableConfig.tableCol track by $index"
                                            width="{{itemCol.width}}" ng-show="!!itemCol.isShow"
                                            title="{{item[itemCol.dataField]}}">
                                            <div ng-switch="itemCol.type">
                                                <div ng-switch-when="click">
                                                    <a class="btn-operate m-r-xs"
                                                        ng-click="detailTableInfo.tdClick(item, itemCol.clickFn)">
                                                        {{item[itemCol.dataField]}}
                                                    </a>
                                                </div>
                                                <div ng-switch-default>
                                                    <span>{{item[itemCol.dataField]}}</span>
                                                </div>
                                            </div>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                        <div class="no-data w-full text-center p-t" ng-show="detailTableInfo.dataList.length === 0" translate>
                            暂时没有数据
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>